The present invention relates to computer graphics, and more particularly to anisotropic texture sampling in a computer graphics processing pipeline.
In the field of computer graphics, texture mapping refers to a process for mapping an image onto a surface of a graphical object to enhance the visual realism of a generated image. Intricate detail at the surface of an object is very difficult to model using polygons or other geometric primitives, and doing so can greatly increase the computational cost of the object. Texture mapping is a more efficient way to represent fine detail on the surface of an object. A xe2x80x9ctexture mapxe2x80x9d is a digital image, which is also referred to as the xe2x80x9csource image.xe2x80x9d The texture map is typically rectangular in shape and has its own (u, v) coordinate space. Individual elements of the texture map are referred to as xe2x80x9ctexels.xe2x80x9d In a texture mapping operation, a texture or xe2x80x9csource imagexe2x80x9d is mapped to the surface of a graphical model as the model is rendered to create a target image.
As digital images, the source and the target images are sampled at discrete points, usually on a grid of points with integer coordinates. In the source image, texels are usually located at integer coordinates in the (u, v) coordinate system. Similarly, in the target image, pixels are usually located at integer coordinates in the (x, y) coordinate system.
The process of texture mapping generally includes sampling data from the source image to compute an intensity value for a pixel in the destination image. The texels to be sampled for a given pixel are typically identified by mapping a region in the destination image into the source image. Texels neighboring the mapped point in the source image are then sampled, weighted and summed to compute the intensity value for a pixel. This process is then repeated for additional pixels in the destination image.
While texture mapping is an effective technique for generating images with surface detail, present approaches often produce unacceptable amounts of distortion. Distortion results because, in practice, several approximations are made in computing pixel intensities. In real time graphics systems, the problem is particularly acute because each pixel value must be computed quickly so that the entire image can be generated within a fixed time period. Because of these rigorous timing constraints, real time systems either do not support texture mapping or make additional approximations that reduce image quality.
To simplify texture mapping operations, some systems make approximations in determining the shape of a sampling region in the source image. The sampling region is the area in the source image that defines which texels to sample in computing a pixel intensity, and is sometimes referred to as the pixel footprint in the source image. The footprint can have a different shape for each target pixel. It is often difficult to find the exact shape of the footprint and the weighting factors to apply to the texels inside the footprint. Some systems make the approximation of using the same shape for the filter at every point, although they may allow the size of the filter to vary. This approach often leads to artifacts in the final image that degrade image quality.
Filters that approximate footprints with squares or circles of variable size are referred to as isotropic filters. A circle is truly isotropic since it has the same length in all directions. When used with a rectangular array of texels, a square is essentially isotropic, since it has equal dimensions horizontally and vertically.
Isotropic filtering can produce distortion because the same filter shape is used regardless of the extent to which the mapping is non-uniform from destination to source image. In areas of the source image where the actual footprint is highly elongated, an essentially isotropic shape such as a square or a circle is a poor substitute for the footprint, even if the size is adjustable. Since an isotropic filter only has one shape, it can not accurately capture texels in an elongated footprint. For example, a square filter cannot accurately sample texel values from a quadrilateral footprint elongated in one direction. Sampling texels outside the actual footprint can cause blurring. Not sampling texels in the footprint, on the other hand, can cause the final image to sparkle due to aliasing. One example of filtering, multum in parvo (MIP) mapping, also suffers from this disadvantage.
During MIP mapping, a number of texture maps are stored at different resolutions. For example, if the one texture is at 512xc3x97512 texels, textures at 256xc3x97256, 128xc3x97128, 64xc3x9764, etc. can also be stored. This xe2x80x9cpyramidxe2x80x9d of texture maps at varying resolution can be used to find the best fit for an isotropic filter on the footprint of the pixel mapped into the texture. The process begins by finding the two textures where the footprint is closest in size to the size of the filter. It then performs interpolation for the two textures that fit the footprint most closely to compute two intermediate values. Finally, it interpolates between the two intermediate values to find a value for the pixel.
MIP mapping is suited for handling only square pixels that are oriented in a predetermined manner in texture space. As such, when a projection of a pixel in texture space varies in shape and size, this texture mapping process is subject to aliasing and blurring.
There is thus a need for a way of benefiting from the process simplification afforded by isotropic filtering while reducing the complications of blurring and aliasing during texture mapping processes such as MIP mapping.
A system, method and article of manufacture are provided for anisotropic filtering during texture sampling. A description of a region, e.g. pixel footprint in a source image, to be texture sampled is initially received. Thereafter, the region is subdivided based on the description into a plurality of samples with a predetermined shape for mapping textures onto the samples. By subdividing the region in the source image into a plurality of samples having a predetermined shape, the region may be covered by samples that may be configured to be more suitable for MIP mapping, thus allowing efficient texture sampling while reducing blurring, aliasing and other visual artifacts.
In one embodiment of the present invention, the predetermined shape of the samples may have a substantially square configuration, and the region may have a substantially rectangular configuration. It should be noted that the rectangular region may be arbitrarily oriented. As an option, it may be determined whether the region has a rectangular configuration. If the region does not have a rectangular configuration, a rectangular shape corresponding to the region may be approximated.
In another embodiment of the present invention, the subdivision of the region may include calculating a length and an area of the region such that the subdivision may be determined based on the calculated length and area. In particular, the subdivision may be determined based on an aspect ratio (r) which equals length (L) squared divided by area (A).
If the aspect ratio (r) is greater than a predetermined value, the rectangle may be augmented, thus adjusting the aspect ratio (r) to a desired value. Further, a level of detail (LOD) value associated with the region may be calculated. If the LOD value is less than a predetermined value such as zero (0), the present invention may be capable of refraining from subdividing the region into samples.
In still another embodiment of the present invention, a test may be performed in order to determine the manner in which the region is to be subdivided based on the aspect ratio (r). Specifically, it may be determined if log2(r) greater than LOD. In operation, the subdivision of the samples may be determined using the expression xc2xdxe2x88x921/(2*r) if it is determined that log2(r) is less than or equal to LOD. If, on the other hand, it is determined that log2(r) greater than LOD, the subdivision of the samples may be determined using the expression xc2xdxe2x88x921/(2*2LOD). It should be noted that such expressions relate to the spacing of centers of the samples with respect to the center of the region in the source image.